package com.example.test;

import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;

public class Demo01 {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("asdf");
        list.add("asddsvbds");
        list.add("asere");
        list.add("fgfr");
        list.add("fjvndjv");
        List<String> collect = list.stream()
                .filter(v -> v.equals("a"))
                .collect(Collectors.toList());
        System.out.println(collect);

        String a="A";
        assertAndThrowExp(() -> StringUtils.isEmpty(a),"error");

        String b="ssd%sssds%sd";
        String format = String.format(b, "2.0.8B47","aaaa");
        System.out.println("format = " + format);
    }

    public <T> void test(Consumer<T> a, BiConsumer<T,String> b, Function<T,String> c){

    }

    public static void assertAndThrowExp(Supplier<Boolean> fun, String errMsg){
        if (fun.get()){
            System.out.println(errMsg);
        }else {
            System.out.println("pass");
        }
    }
}
